home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / Library / Utils / Timer.as < prev    next >
Text File  |  2007-09-27  |  1KB  |  53 lines

  1. class Library.Utils.Timer
  2. {
  3.    static var TIMER_COUNT_UP = 1;
  4.    static var TIMER_COUNT_DOWN = -1;
  5.    static var BASE_FRAMERATE = 30;
  6.    function Timer()
  7.    {
  8.       this.nTimeSpent = 0;
  9.       this.nMethod = Library.Utils.Timer.TIMER_COUNT_UP;
  10.       this.nFrameRate = Library.Utils.Timer.BASE_FRAMERATE;
  11.       this.bTimerActive = false;
  12.    }
  13.    function doEnterFrame()
  14.    {
  15.       if(this.bTimerActive)
  16.       {
  17.          this.nTimeSpent += this.nMethod;
  18.       }
  19.    }
  20.    function doStartTimer()
  21.    {
  22.       this.bTimerActive = true;
  23.    }
  24.    function doStopTimer()
  25.    {
  26.       this.bTimerActive = false;
  27.    }
  28.    function setTime(__nTime)
  29.    {
  30.       this.nTimeSpent = __nTime * (this.nFrameRate / 1000);
  31.    }
  32.    function doResetTime()
  33.    {
  34.       this.nTimeSpent = 0;
  35.    }
  36.    function get Time()
  37.    {
  38.       return Math.round(this.nTimeSpent / (this.nFrameRate / 1000));
  39.    }
  40.    function get Frames()
  41.    {
  42.       return this.nTimeSpent;
  43.    }
  44.    function set Method(__n)
  45.    {
  46.       this.nMethod = __n;
  47.    }
  48.    function set FrameRate(__n)
  49.    {
  50.       this.nFrameRate = __n;
  51.    }
  52. }
  53.